import { Cache } from "../../cache/Cache";
import { SGangFightsToplist } from "../../../../Message/Public/SGangFightsToplist";
import { SGangFightsTeamInfo } from "../../../../Message/Public/SGangFightsTeamInfo";
import { SEntityId } from "../../../../Message/Public/SEntityId";
import { SLookupPlayerReply } from "../../../../Message/Game/SLookupPlayerReply";
import { GangFightsApplyTeamListPanel } from "./GangFightsApplyTeamListPanel";
import { GangFightsMyTeamInfoPanel } from "./GangFightsMyTeamInfoPanel";
//class GangFightsTeamPanel
    
    export  class GangFightsTeamPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            if (Cache.instance.gangFights.myInfo && !(Cache.instance.gangFights.myInfo.teamId == 0)) 
            {
                this.addChild(this.gangFightsMyTeamInfoPanel);
            }
            else 
            {
                this.addChild(this.gangFightsApplyTeamListPanel);
            }
            return;
        }

        public updateTopList(arg1: SGangFightsToplist): void
        {
            this.gangFightsApplyTeamListPanel.updateGangFightsTopList(arg1);
            this.updateVisible();
            return;
        }

        public updateTeamInfo(arg1: SGangFightsTeamInfo): void
        {
            this.gangFightsMyTeamInfoPanel.updateTeamInfo(arg1);
            this.updateVisible();
            return;
        }

        public setPlayerNotOnline(arg1: SEntityId): void
        {
            this._gangFightsMyTeamInfoPanel.setPlayerNotOnline(arg1);
            return;
        }

        public updateTeamPlayerInfo(arg1: SLookupPlayerReply): void
        {
            this._gangFightsMyTeamInfoPanel.updateTeamPlayerInfo(arg1);
            return;
        }

        public updateVisible(): void
        {
            if (Cache.instance.gangFights.myInfo && !(Cache.instance.gangFights.myInfo.teamId == 0)) 
            {
                if (this._gangFightsApplyTeamListPanel && this._gangFightsApplyTeamListPanel.parent) 
                {
                    this._gangFightsApplyTeamListPanel.parent.removeChild(this._gangFightsApplyTeamListPanel);
                }
                this.addChild(this.gangFightsMyTeamInfoPanel);
            }
            else 
            {
                if (this._gangFightsMyTeamInfoPanel && this._gangFightsMyTeamInfoPanel.parent) 
                {
                    this._gangFightsMyTeamInfoPanel.parent.removeChild(this._gangFightsMyTeamInfoPanel);
                }
                this.addChild(this.gangFightsApplyTeamListPanel);
            }
            return;
        }

        public get gangFightsApplyTeamListPanel(): GangFightsApplyTeamListPanel
        {
            if (!this._gangFightsApplyTeamListPanel) 
            {
                this._gangFightsApplyTeamListPanel = new GangFightsApplyTeamListPanel();
            }
            return this._gangFightsApplyTeamListPanel;
        }

        public get gangFightsMyTeamInfoPanel(): GangFightsMyTeamInfoPanel
        {
            if (!this._gangFightsMyTeamInfoPanel) 
            {
                this._gangFightsMyTeamInfoPanel = new GangFightsMyTeamInfoPanel();
            }
            return this._gangFightsMyTeamInfoPanel;
        }

        /* internal */ /* var */_gangFightsApplyTeamListPanel: GangFightsApplyTeamListPanel;

        /* internal */ /* var */_gangFightsMyTeamInfoPanel: GangFightsMyTeamInfoPanel;
    }
